/* eslint-disable */
import "./public-path";
import { createApp } from 'vue';
import App from './App.vue';
import router from './router'

// @ts-ignore
let instance = null;

function render(props = {}) {
  // @ts-ignore
  const { container } = props;
  instance = createApp(App);
  instance.use(router)
  instance.mount(container ? container.querySelector('#app') : '#app');
}

// @ts-ignore
if (!window.__POWERED_BY_QIANKUN__) {
  render();
}

export async function bootstrap() {
  console.log('vue app bootstrap');
}

// @ts-ignore
export async function mount(props) {
  render(props);
  // @ts-ignore
  instance.config.globalProperties.$onGlobalStateChange = props.onGlobalStateChange;
  // @ts-ignore
  instance.config.globalProperties.$setGlobalState = props.setGlobalState;
}

// @ts-ignore
export async function unmount() {
    // @ts-ignore
  instance.unmount();
  // @ts-ignore
  instance._container.innerHTML = '';
  instance = null;
}
